package com.sinosoft.dsp.platform.action;

/**
 * 平台中单例的场景类型，<br>
 * 通用可以通过调用该枚举类来获得要刷新的场景。
 * 
 * @author 潘巍（Peter Pan）
 * @since 2011-4-6 下午09:37:38
 */
public enum SingletonSceneType {
	// 导航场景
	NAVI("navi",
			new String[] { SingletonSceneType.SINGLETON_SCENE_ID_PORTAL_NAVI }),

	// 主编辑场景
	CONTENT(
			"content",
			new String[] { SingletonSceneType.SINGLETON_SCENE_ID_PORTAL_CONTENT }),

	// 日志场景
	LOG(
			"log",
			new String[] { SingletonSceneType.SINGLETON_SCENE_ID_PORTAL_LOGBAR }),

	// TAB页签场景
	TAB("tab",
			new String[] { SingletonSceneType.SINGLETON_SCENE_ID_MAIN_TABSET }),

	// 弹出窗口场景
	WINDOW(
			"window",
			new String[] { SingletonSceneType.SINGLETON_SCENE_ID_PORTAL_WINDOW }),

	// 默认的场景
	AUTO("auto", null), ;

	SingletonSceneType(String name, String[] sceneIds) {
		this.name = name;
		this.sceneIds = sceneIds;
	}

	/**
	 * 单例场景ID
	 */
	// Portal的整体内容场景ID
	public static final String SINGLETON_SCENE_ID_PORTAL_CONTENT = "portal_content";
	// Portal的导航场景ID
	public static final String SINGLETON_SCENE_ID_PORTAL_NAVI = "portal_navigation";
	// Portal的日志场景ID
	public static final String SINGLETON_SCENE_ID_PORTAL_LOGBAR = "portal_logbar";
	// Portal的窗口场景ID
	public static final String SINGLETON_SCENE_ID_PORTAL_WINDOW = "portal_window";
	// 主窗口Tab场景ID
	public static final String SINGLETON_SCENE_ID_MAIN_TABSET = "main-tabSet";

	/**
	 * 单例场景名称
	 */
	private final String name;

	/**
	 * 对于的单例场景ID集合
	 */
	private final String[] sceneIds;

	public String getName() {
		return this.name;
	}

	public String[] getSceneIds() {
		return this.sceneIds;
	}

	public String getSceneIdString() {
		String rtn = "";
		for (String a : this.sceneIds) {
			rtn += ",";
			rtn += a;
		}
		return rtn.substring(1);
	}

	/**
	 * 通过单例场景名称，获得场景单例对象
	 * 
	 * @param name
	 * @return
	 */
	public static SingletonSceneType getScene(String name) {
		for (SingletonSceneType r : SingletonSceneType.values()) {
			if (r.getName().equalsIgnoreCase(name))
				return r;
		}
		return null;
	}
}
